package org.apache.rocketmq.example.kang.consumer.sample;

import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;

public class SampleProductTest {

    public static void main(String[] args) throws Exception {

        DefaultMQProducer producer = new DefaultMQProducer(SampleConfig.CONSUMER_GROUP);
        producer.setNamesrvAddr(SampleConfig.NAMESRV_ADDR);
        producer.start();

        //发送单条消息
        Message msg = new Message(SampleConfig.TOPIC, "hello rocketmq".getBytes());
        SendResult sendResult = null;
        sendResult = producer.send(msg);

        for (int i = 0; i < 10; i++) {
            sendResult = producer.send(msg);
        }
        //　输出结果
        System.out.printf("%s%n", sendResult);

        //　使用完毕后，关闭消息发送者
        producer.shutdown();

    }
}
